/*
 * @Author: 王灿
 * @Date: 2019-10-27 15:07:02
 * @Description: file content
 */

// import router from '@/router'
// import store from '../store'
// router.beforeEach((to, from, next) => {
//     if (Object.keys(store.getters.dataDic).length) {
//         next()
//     } else {
//         store.dispatch('GetAllDictionaryKeyValue').then(() => {
//             next()
//         })
//     }
// })
import Vue from 'vue'

function havePermissions(functionCode) {
    // 用户权限按钮
    const functionLists = ['sysLogins']
    if (functionLists === undefined || functionLists === null) {
        return false;
    }
    if (Array.isArray(functionLists) && functionLists.length) {
        return functionLists.some(x => functionCode.includes(x))
    }
    return true
}

Vue.directive('permissions', {
    bind(el, { value }) {
        if (!havePermissions(value)) {
            if (el.parentNode) {
                el.parentNode.removeChild(el)
            } else {
                el.style.display = 'none'
            }
        }
    }
})

Vue.prototype.$returnPermissions = havePermissions